package com.hxy.health.platform.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hxy.health.platform.dao.GalleryMapper;
import com.hxy.health.platform.pojo.Gallery;
import com.hxy.health.platform.service.GalleryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GalleryServiceImpl implements GalleryService {
    @Autowired
    private GalleryMapper galleryMapper;

    /**
     * 查询所有的服务
     * @return
     */
    @Override
    public List<Gallery> getAll() {
        return galleryMapper.getAll();
    }

    /**
     * 查询服务详情
     * @param id
     * @return
     */
    @Override
    public Gallery getById(Integer id) {
        return galleryMapper.selectByPrimaryKey(id);
    }

    /**
     * 搜索服务
     * @param question
     * @return
     */
    @Override
    public PageInfo<Gallery> search(Integer pageNum, Integer pageSize,String question) {
        PageHelper.startPage(pageNum, pageSize);
        List<Gallery> galleries = galleryMapper.search(question);
        PageInfo pageInfo = new PageInfo(galleries);
        return pageInfo;
    }
}
